package com.macrounion.atv.controller.api;

import com.macrounion.atv.service.dto.req.VirtualReqDto;
import com.macrounion.atv.service.entity.ext.VirtualExt;
import com.macrounion.base.service.dto.PageRespDto;
import com.macrounion.base.service.exception.BusinessException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import com.macrounion.atv.processor.VirtualChannelProcessor;
import com.macrounion.atv.service.entity.User;
import com.macrounion.atv.service.entity.VirtualChannel;
import com.macrounion.atv.service.service.VirtualChannelService;
import com.macrounion.base.controller.api.BaseApiController;

import java.util.List;

@RestController
@RequestMapping("/api/virtual")
public class VirtualChannelApiController extends BaseApiController<VirtualChannel, VirtualChannel, VirtualChannelProcessor, VirtualChannelService, VirtualChannel,User> {

    @PostMapping("/requestPageList")
    public PageRespDto<VirtualExt> requestPageList(@RequestBody VirtualReqDto virtualReqDto){
        return processor.requestPageList(virtualReqDto);
    }

    @GetMapping("/getList")
    public List<VirtualChannel> getList(){
        return processor.getList();
    }

    /**
     * 保存公式
     * @param virtual
     * @return
     */
    @PostMapping("/saveFx")
    public Boolean saveFx(@RequestBody VirtualChannel virtual){
        if(virtual==null || StringUtils.isEmpty(virtual.getId()))
            throw new BusinessException(201,"参数错误");

        return processor.saveFx(virtual);
    }
}